import Vue from 'vue'
import VueRouter from 'vue-router'
import Layout from '@/views/Layout'
import { Tabbar, TabbarItem, Button, NavBar, Form, Field, Toast, Dialog } from 'vant'
import Home from '@/views/Home'
import Search from '@/views/Search'
import Consult from '@/views/Consult'
import User from '@/views/User'
import Login from '@/views/Login'
import Registe from '@/views/Registe'
import Is404 from '@/views/Is404'

Vue.use(Toast)
Vue.use(Dialog)

Vue.use(Form)
Vue.use(Field)
Vue.use(NavBar)
Vue.use(Button)
Vue.use(Tabbar)
Vue.use(TabbarItem)

Vue.use(VueRouter)

const routes = [
  { path: '/', redirect: '/layout/home' },
  {
    path: '/layout',
    component: Layout,
    children: [{ path: '/layout/home', component: Home },
      { path: '/layout/search', component: Search },
      { path: '/layout/consult', component: Consult },
      { path: '/layout/user', component: User }
    ]
  },
  { path: '/login', component: Login },
  { path: '/registe', component: Registe },
  { path: '*', component: Is404 }

]

const router = new VueRouter({
  routes
})

export default router
